package com.example.riceexambackend.dao.mapper;

import com.example.riceexambackend.dao.dataobject.ExamDO;
import com.example.riceexambackend.dao.dataobject.ExamQuestionDO;
import com.example.riceexambackend.dao.dataobject.QuestionTypeDO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ExamQuestionMapper {

    /**
     * 插入试卷-题目记录
     * @param examQuestionDO
     */
    @Insert("insert into t_exam_question (exam_id, question_id) values (#{examId}, #{questionId})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    void insertExam(ExamQuestionDO examQuestionDO);


    /**
     * 根据examId删除试卷-题目记录
     * @param examId
     */
    @Delete("update t_exam_question set delete_flag = 1 where exam_id = #{examId}")
    void deleteByExamId(@Param("examId") Long examId);

    /**
     * 根据examId查询全部关联试卷-题目记录
     * @param examId
     */
    @Select("select * from t_exam_question where delete_flag = 0 and exam_id = #{examId}")
    List<ExamQuestionDO> selectByExamId(@Param("examId") Long examId);
}
